<extend name="./Template/Admin/Index_main.html" />

<block name="main">
    <link rel="stylesheet" type="text/css" href="/Apps/Common/Builder/admin.min.css">
    <script src="/inc/static/jquery-2.0.3.min.js"></script> 
        <!-- 数据列表 -->
        <div class="toolbar" style="margin-bottom:20px;"> 
            <a class="btn btn-info" href="{:U('export')}">备份数据库</a>
            <a class="btn btn-success" href="{:U('index')}">数据库结构</a>
        </div>
        还原将覆盖现有数据，强烈建议您在空间服务商那里也备份一次，以免程序出错！
        <div class="data-table">
            <div class="panel panel-default">
                <table class="table table-bordered table-responsive table-striped table-hover">
                    <thead>
                        <tr>
                            <th width="200">备份名称</th>
                            <th width="80">卷数</th>
                            <th width="80">压缩</th>
                            <th width="80">数据大小</th>
                            <th width="200">备份时间</th>
                            <th>状态</th>
                            <th width="120">操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        <volist name="list" id="data">
                            <tr>
                                <td>{$data.time}</td>
                                <td>{$data.part}</td>
                                <td>{$data.compress}</td>
                                <td>{$data.size}</td>
                                <td>{$key}</td>
                                <td>-</td>
                                <td class="action">
                                    <a class="label label-danger db-import" href="{:U('do_import?time='.$data['time'])}">还原</a>&nbsp;
                                    <a class="label label-danger ajax-get confirm" href="{:U('del?time='.$data['time'])}">删除</a>
                                </td>
                            </tr>
                        </volist>
                    </tbody>
                </table>
            </div>
        </div>
     
        <script type="text/javascript">
            $(function(){
                $(".db-import").click(function() {
                    if ($(this).hasClass('confirm')) {
                        if (!confirm('确认要执行该操作吗?')) {
                            return false;
                        }
                    }
                    var self = this, status = ".";
                    $.get(self.href, success, "json");
                    window.onbeforeunload = function(){ return "正在还原数据库，请不要关闭！" }
                    return false;
                    function success(data){
                        if(data.status){
                            if(data.gz){
                                data.info += status;
                                if(status.length === 5){
                                    status = ".";
                                }else{
                                    status += ".";
                                }
                            }
                            $(self).parent().prev().text(data.info);
                            if(data.part){
                                $.get(self.href,
                                    {"part" : data.part, "start" : data.start},
                                    success,
                                    "json"
                                );
                            }else{
                                window.onbeforeunload = function(){ return null; }
                            }
                        }else{
                            $.alertMessager(data.info, 'danger');
                        }
                    }
                });
            });
        </script>
        <script src="/Apps/Common/Builder/admin.min.js"></script>
</block>

